﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using SiteManager;

public partial class Admin_eScheduledDentists : System.Web.UI.Page
{
    Manager mgr = new Manager(true, "ConnectionString");
    protected localFunction obj = new localFunction();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            Session["ParentForm"] = "eScheduldForm";
            FillGrid();

            foreach (GridViewRow gvr in grdEscheduledDoctors.Rows)
            {
                int drID = Convert.ToInt32(grdEscheduledDoctors.DataKeys[gvr.RowIndex].Values["Id"]);

            }
        }

    }

    private void FillGrid()
    {
        DataSet ds = CustomRepository.CustumDataSetFunction("get_LastWeak_eSheduledDentists", "tbl");

        grdEscheduledDoctors.DataSource = ds;
        grdEscheduledDoctors.DataBind();

        //  DataSet dss = mgr.ExecuteQuery("Select date = convert(varchar(10), eventstart, 102)From CalendarEvent where doctorId=1002897");

    }
    protected void grdEscheduledDoctors_RowDataBound(object sender, GridViewRowEventArgs e)
    {



        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            int drID = Convert.ToInt32(grdEscheduledDoctors.DataKeys[e.Row.RowIndex].Values[0]);
            string qry = "SELECT  convert(varchar(25), eventstart, 1) AS dateonly,convert(varchar(25), eventstart, 108) AS [time],Id From DentistCalendar where eventstart >= DATEADD(day,-7, GETDATE()) and dentistId=" + drID;
            DataSet dss = CustomRepository.CustumDataSetFunction(qry, "tbl");
            DataList DataList1 = ((DataList)e.Row.FindControl("DLTime"));
            DataList1.DataSource = dss;
            DataList1.DataBind();
            DataList DataList2 = ((DataList)e.Row.FindControl("dlDate"));
            DataList2.DataSource = dss;
            DataList2.DataBind();


        }


    }
}
